<template>
  <div class="app-warp">
    <PageHeader />
    <UiNavApp />
    <UiAplayer />
  </div>
</template>

<script>
import UiNavApp from './views/UiNavApp'
import UiAplayer from '../../components/UiAplayer'
import PageHeader from '../../components/PageHeader'
export default {
  name: 'App',
  components: {
    UiNavApp,
    UiAplayer,
    PageHeader
  },
  data() {
    return {
      weatherMap: {
        '晴': 'icon-qingtian',
        '多云': 'icon-duoyun',
        '扬沙': 'icon-yangsha',
        '霾': 'icon-mai',
        '大雨': 'icon-dayu',
        '中雨': 'icon-zhongyu',
        '小雨': 'icon-xiaoyu',
        '雷阵雨': 'icon-leizhenyu',
        '浮尘': 'icon-fuchen',
        '雾': 'icon-wu',
        '大雪': 'icon-daxue',
        '中雪': 'icon-zhongxue',
        '小雪': 'icon-xiaoxue',
        '雨夹雪': 'icon-yujiaxue',
        '阴': 'icon-yintian'
      },
      weather: '',
      city: '',
      temp: ''
    }
  },
  created() {
    this.getWeather()
  },
  methods: {
    getWeather() {
      this.$http.jsonp('https://api.asilu.com/weather/')
        .then(({ body }) => {
          this.city = body.city
          this.temp = body.weather[0].temp
          this.weather = body.weather[0].weather
        })
    },
    getWeatherIcon(weather) {
      const weathers = weather.split('转')
      if (weathers.length > 0) {
        return this.weatherMap[weathers[0]]
      }
      return this.weatherMap[weather]
    }
  }
}
</script>

<style lang="less">
  .slide-enter-active, .slide-leave-active {
    transition: all .5s;
  }
  .slide-leave-to,.slide-enter{
    opacity: 0;
    transform: translateY(-40px);
  }
  html,body{
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
  }
  .app-warp{
    width: 100%;
    height: 100%;
  }
</style>
